package com.adityayadav.peekaboo;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.net.Socket;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;

public class Peeker extends JFrame{
	
	public Peeker(String url, Socket socket){
		this.setResizable(true);
		this.setTitle(url);
		this.setMinimumSize(new Dimension(640,480));
		this.setSize(new Dimension(800,600));
		this.setLayout(new BorderLayout());
		
		Processors processors = SocketRegistry.getInstance().get(socket);
		JTabbedPane tabbedPane = new JTabbedPane();
		JTextPane inText = new JTextPane();
		//inText.setAutoscrolls(true);
		inText.setText(new String(processors.getInProcessor().getBuffer()));
		JScrollPane inScroll = new JScrollPane(inText);
		tabbedPane.addTab("In",inScroll);
		JTextPane outText = new JTextPane();
		outText.setText(new String(processors.getOutProcessor().getBuffer()));
		//outText.setAutoscrolls(true);
		JScrollPane outScroll = new JScrollPane(outText);
		tabbedPane.addTab("Out",outScroll);
		this.getContentPane().add(tabbedPane,BorderLayout.CENTER);
		this.setVisible(true);
	}
}
